﻿using System;
using System.Collections.Generic;

using System.Text;

namespace CommonTools
{
    public class Helper
    {
        public static string MoneyString(decimal d) {
            return String.Format("{0:0,0}", d);
        }
        public static string PercentString(decimal l)
        {
            return String.Format("{0}%", l);
        }
        public static long StringToLong(String str)
        {   
            long ret = 0;
            try{
                ret =long.Parse(str.Trim().Replace(",", "").Replace("%",""));
            }catch{}
            return ret;
        }

        public static int StringToInt(String str)
        {   
            int ret = 0;
            try{
                ret = int.Parse(str.Trim().Replace(",", "").Replace("%",""));
            }catch{}
            return ret;
        }
        public static DateTime StringToDateTime(String str)
        {
            // 11/17/2009 aa:aa:22 AM
            DateTime date = DateTime.Today;
            if (str != null)
            {
                str = str.Trim();
                if (str.Length >= 10)
                    str = str.Substring(0, 10);
                date = DateTime.Parse(str);
            }
            return date;
        }
    }
}
